package logq

import (
	"gitee.com/slclub/aliyun-oss/conf"
	"gitee.com/slclub/aliyun-oss/utils"
	"github.com/slclub/glog"
)

/**
 * example:
 * 		log.Info("[HANDLE_INFO][ECHO]", "show info done!")
 * 		log.InfoF("[HANDLE][INFO]%s", "That is fun joke")
 *		log.Debug(...)
 * 		log.DebugF(format, ...string)
 */
func InitLog() {
	log_path := conf.Config.Log.LogAbsPath
	if conf.Config.Log.LogAbsPath == "" {
		log_path = utils.APP_PATH
	}
	glog.Set("path", log_path, conf.Config.Log.LogRelPath)
	glog.Set("name", conf.Config.Log.LogName)
	glog.Set("head", conf.Config.Log.LogHeader)
	glog.Set("stderr", conf.Config.Log.Stderr)
	if conf.Config.Log.LogLevel > 0 {
		glog.Set("debug", conf.Config.Log.LogLevel)
	}
	glog.Set("debug", conf.Config.Log.Debug)
}

// 如果想打印日志时带上文件名和行数，这个值需要对应上调度层级，才可以正确的打印我们代码文件
// warn 级别的错误自动带入文件名和行数。可以快速的定位日志代码位置
var log_depath = 1

// info
func Info(args ...interface{}) {
	glog.InfoDepth(log_depath, args...)
}
func InfoF(format string, args ...interface{}) {
	glog.Infof(format, args...)
}

// debug
func Debug(args ...interface{}) {
	glog.DebugDepth(log_depath, args...)
}
func DebugF(format string, args ...interface{}) {
	glog.Debugf(format, args...)
}

// warnning
func Warn(args ...interface{}) {
	glog.WarnningDepth(log_depath, args...)
}
func WarnF(format string, args ...interface{}) {
	glog.Warnningf(format, args...)
}

//error
func Error(args ...interface{}) {
	glog.ErrorDepth(log_depath, args...)
}
func ErrorF(format string, args ...interface{}) {
	glog.Errorf(format, args...)
}

func Fatal(args ...interface{}) {
	glog.FatalDepth(log_depath, args...)
}
